import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';

export const columns: BasicColumn[] = [
  {
    title: 'ID',
    dataIndex: 'id',
    width: 80,
    align: 'center',
  },
  {
    title: '姓名',
    dataIndex: 'fname',
    width: 160,
    align: 'center',
  },
  {
    title: '工号',
    dataIndex: 'fnumber',
    width: 160,
    align: 'center',
  },
  //====
  {
    title: '教学课时',
    dataIndex: 'jxks',
    width: 100,
    align: 'center',
  },
  {
    title: '教科研积分',
    dataIndex: 'jkyjf',
    width: 100,
    align: 'center',
  },
  {
    title: '教科研建设积分',
    dataIndex: 'jkyjsjf',
    width: 160,
    align: 'center',
  },
  {
    title: '管理与公共服务积分',
    dataIndex: 'glyggfwjf',
    width: 160,
    align: 'center',
  },
  //====
  {
    title: '备注',
    dataIndex: 'tips',
    width: 160,
    align: 'center',
  },
  // {
  //   title: '排序',
  //   dataIndex: 'sort',
  //   width: 50,
  //   sorter: true,
  // },

  {
    title: '是否认证',
    dataIndex: 'authentication',
    width: 80,
    customRender: ({ record }) => {
      const status = record.authentication;
      const enable = ~~status === 1;
      const color = enable ? 'green' : 'red';
      const text = enable ? '是' : '否';
      return h(Tag, { color: color }, () => text);
    },
  },
  {
    title: '创建时间',
    dataIndex: 'create_time',
    width: 180,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'fname',
    label: '教师名称',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'fnumber',
    label: '员工号',
    component: 'Input',
    colProps: { span: 8 },
  },
];

//新增弹窗form字段
export const formSchema: FormSchema[] = [
  {
    label: 'ID',
    field: 'id',
    component: 'Input',
    defaultValue: 0,
    show: false,
  },
  {
    field: 'fname',
    label: '教师姓名',
    component: 'Input',
    required: true,
  },
  {
    field: 'fnumber',
    label: '员工号',
    component: 'Input',
    required: true,
  },
  {
    label: '职称',
    field: 'type',
    component: 'Input',
    defaultValue: '',
    required: false,
  },
  {
    label: '部门',
    field: 'class',
    component: 'Input',
    defaultValue: '',
    required: false,
  },
  // {
  //   label: '部门',
  //   field: 'class',
  //   component: 'ApiSelect',
  //   componentProps: {
  //     api: getDeptList,
  //     labelField: 'dept_name',
  //     valueField: 'dept_id',
  //   },
  //   required: true,
  // },
  {
    field: 'jxks',
    label: '教学课时',
    component: 'Input',
    defaultValue: 0,
    show: false,
  },
  {
    field: 'jkyjf',
    label: '教科研积分',
    component: 'Input',
    defaultValue: 0,
    show: false,
  },
  {
    field: 'jkyjsjf',
    label: '教科研建设积分',
    component: 'Input',
    defaultValue: 0,
    show: false,
  },
  {
    field: 'glyggfwjf',
    label: '管理与公共服务积分',
    component: 'Input',
    defaultValue: 0,
    show: false,
  },
  {
    field: 'tips',
    label: '备注',
    component: 'InputTextArea',
    defaultValue: '',
    show: true,
  },
  {
    field: 'authentication',
    label: '是否已认证',
    component: 'RadioButtonGroup',
    defaultValue: 0,
    componentProps: {
      options: [
        { label: '是', value: 1 },
        { label: '否', value: 0 },
      ],
    },
    required: true,
  },
];
